package com.mzj.saas.jobs.lock.executor;

import com.mzj.saas.jobs.lock.service.LockService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 智能锁状态(亚略特)
 */
@JobHandler(value = "lockStatusExecutor")
@Component
public class LockStatusExecutor extends IJobHandler {
	private static Logger log = LoggerFactory.getLogger(LockStatusExecutor.class);

	@Autowired
	private LockService lockService;

	@Override
	public ReturnT<String> execute(String arg0) throws Exception {
		long time = System.currentTimeMillis();
		try {
			lockService.heartbeatStatus();
		} catch (Exception e) {
			log.error(e.getMessage(), e);
		}

		long useTime = System.currentTimeMillis() - time;
		log.info("----> lockStatusExecutor end, use time: {}", useTime);

		return SUCCESS;
	}

}
